/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.muni.fi.pa036.kiss.Entity;

/**
 *
 * @author Vasa
 */
public class MajetekKolejeDTO {
    
    private Long id;
    private KolejDTO kolej;
    private String nazev;
    private String umisteni;
    private Double cena;

  public Long getId () {

    return this.id;
  }

  public MajetekKolejeDTO setId ( final Long id ) {

    if ( id != null ) {

      this.id = new Long ( id.longValue () );
    }

    return this;
  }

    public Double getCena() {
        return cena;
    }

    public void setCena(Double cena) {
        this.cena = cena;
    }

    public KolejDTO getKolej() {
        return kolej;
    }

    public void setKolej(KolejDTO kolej) {
        this.kolej = kolej;
    }

    public String getNazev() {
        return nazev;
    }

    public void setNazev(String nazev) {
        this.nazev = nazev;
    }

    public String getUmisteni() {
        return umisteni;
    }

    public void setUmisteni(String umisteni) {
        this.umisteni = umisteni;
    }

  @Override
  public boolean equals ( final Object rhs ) {

    if ( this == rhs ) return true;

    if ( rhs == null ) return false;

    if ( this.getClass () != rhs.getClass () ) return false;

    MajetekKolejeDTO c = (MajetekKolejeDTO) rhs;

    return this.id == null ? c.id == null : this.id.equals ( c.id ) &&
        this.kolej == null ? c.kolej == null : this.kolej.equals ( c.kolej ) &&
        this.cena == null ? c.cena == null : this.cena.equals ( c.cena ) &&
        this.nazev == null ? c.nazev == null : this.nazev.equals ( c.nazev ) &&
        this.umisteni == null ? c.umisteni == null : this.umisteni.equals ( c.umisteni );
  }

  @Override
  public int hashCode () {

    final int[] hashCodes = {
        (this.id == null) ? 0 : this.id.hashCode (),
        (this.kolej == null) ? 0 : this.kolej.hashCode (),
        (this.cena == null) ? 0 : this.cena.hashCode (),
        (this.nazev == null) ? 0 : this.nazev.hashCode (),
        (this.umisteni == null) ? 0 : this.umisteni.hashCode ()
    };

    int hash = 17;
    for ( final int currentHashCode: hashCodes ) {

      hash = hash * 31 + currentHashCode;
    }

    return hash;
  }

  @Override
  public Object clone () {

    try {

      return ( (MajetekKolejeDTO) super.clone () ).setId ( this.id );
    } catch ( CloneNotSupportedException ex ) {

      assert false: "CloneNotSupportedException thrown";
      return null;
    }
  }

  @Override
  public String toString () {

    return this.id + ": " + this.nazev + " na "  + this.umisteni+ " za "  + this.cena
    ;
  }

  /**
   * Determine whether the person has set necessary information
   */
  public void checkState () {

    final boolean noNazev = this.nazev == null || this.nazev.isEmpty ();
    final boolean noCena = this.cena == null;

    if ( noNazev && noCena )  {

      throw new IllegalStateException ( "Nazev a cena musi byt nastaveny" );
    }
  }
}
